package cn.com.b2office.struts2.action;

import java.util.List;

import cn.com.b2office.domain.ItemComment;
import cn.com.b2office.service.ItemCommentService;

import com.opensymphony.xwork2.ActionSupport;

public class ListItemCommentsAction extends ActionSupport {

	private static final long serialVersionUID = 666364480482201991L;

	private ItemCommentService itemCommentService = null;

	private String itemId = null;

	private int pageCount = 1;

	private int pageSize = 15;

	private int totalSize = 0;

	private List<ItemComment> list = null;

	public String execute() throws Exception {
		if (pageCount < 1)
			pageCount = 1;
		if (pageSize < 0)
			pageSize = 15;
		totalSize = itemCommentService.getCommentSize(itemId);
		list = itemCommentService.findComments(itemId, (pageCount - 1)
				* pageSize, pageSize);
		return SUCCESS;
	}

	public List<ItemComment> getList() {
		return list;
	}

	public int getTotalSize() {
		return totalSize;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public String getItemId() {
		return itemId;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageCount() {
		return pageCount;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setItemCommentService(ItemCommentService itemCommentService) {
		this.itemCommentService = itemCommentService;
	}

}
